IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'spLetterHeaderAndFooter_RetrieveAll')
	BEGIN
		PRINT 'Dropping Procedure spLetterHeaderAndFooter_RetrieveAll'
		DROP  Procedure  spLetterHeaderAndFooter_RetrieveAll
	END

GO

PRINT 'Creating Procedure spLetterHeaderAndFooter_RetrieveAll'
GO

CREATE Procedure spLetterHeaderAndFooter_RetrieveAll
	(
		@HeaderFont varchar(50) = null, 
		@HeaderFontSize decimal = null, 
		@HeaderFontStyle varchar(50) = null, 
		@HeaderText varchar(500) = null, 
		@HeaderImagePath varchar(50) = null, 
		@FooterFont varchar(50) = null, 
		@FooterFontSize decimal = null, 
		@FooterFontStyle varchar(50) = null, 
		@FooterText varchar(500) = null
	)
AS
    /* 
    ------------------------------------------------------------------------------
    - Change History
    - --------------
    - Date          Description
    ------------------------------------------------------------------------------
    - 10/23/2007	Initial version created
    ------------------------------------------------------------------------------
    */
	
	SET NOCOUNT ON
	
	-- Retrieve the relevant records
	SELECT  *
	FROM	LetterHeaderAndFooter
	
	WHERE	(@HeaderFont IS NULL OR LetterHeaderAndFooter.HeaderFont LIKE @HeaderFont + '%')
	  AND	(@HeaderFontSize IS NULL OR LetterHeaderAndFooter.HeaderFontSize = @HeaderFontSize)
	  AND	(@HeaderFontStyle IS NULL OR LetterHeaderAndFooter.HeaderFontStyle LIKE @HeaderFontStyle + '%')
	  AND	(@HeaderText IS NULL OR LetterHeaderAndFooter.HeaderText LIKE @HeaderText + '%')
	  AND	(@HeaderImagePath IS NULL OR LetterHeaderAndFooter.HeaderImagePath LIKE @HeaderImagePath + '%')
	  AND	(@FooterFont IS NULL OR LetterHeaderAndFooter.FooterFont LIKE @FooterFont + '%')
	  AND	(@FooterFontSize IS NULL OR LetterHeaderAndFooter.FooterFontSize = @FooterFontSize)
	  AND	(@FooterFontStyle IS NULL OR LetterHeaderAndFooter.FooterFontStyle LIKE @FooterFontStyle + '%')
	  AND	(@FooterText IS NULL OR LetterHeaderAndFooter.FooterText LIKE @FooterText + '%')

	-- Return to calling method
	RETURN
GO
